const os=require("os")
let free1=os.freemem()
let all1=os.totalmem()
//let free=(free1/1024/1024/1024).toFixed(2)    //将剩余内存的单位转换为GB
//let all=(all1/1024/1024/1024).toFixed(2)      //将总内存的单位转换为GB
//rate=((all1-free1)/all1*100).toFixed(2)
//console.log("总内存:"+all+"GB")
//console.log("剩余内存:"+free+"GB")
//console.log("内存使用率:"+rate+"%")
//console.log("========================\n")
//console.log("该计算机的网络信息如下：\n")
//console.log(os.networkInterfaces())
//console.log("========================\n")
//console.log("当前用户的主目录为："+os.homedir())
//console.log("========================\n")
//console.log("当前计算机的临时文件目录为："+os.tmpdir())
//console.log("========================\n")
//console.log("当前主机名：",os.hostname())
//console.log("========================\n")
//console.log("当前操作系统为：",os.type())
//console.log("========================\n")
//console.log("当前操作系统编译时的名称为：",os.platform())
//console.log("========================\n")
//console.log("操作系统的CPU架构为：",os.arch())
//console.log("========================\n")
//console.log("当前操作系统的发行版本为：",os.release())
//console.log("========================\n")
//console.log(os.version())
//console.log("========================\n")
//console.log(os.cpus())
//console.log("========================\n")

//var alltime = os.uptime()                              //获取总秒数
//var sec = alltime % 60                                 //计算秒数
//var allmin = parseInt(alltime / 60)                    //计算总分钟数
//var min = allmin % 60                                  //计算分钟数
//var hour = parseInt(allmin / 60)                       //计算小时数
//console.log("当前计算机运行了" + alltime + "秒")
//console.log("转换后为：%d时%d分%d秒", hour, min, sec)

//console.log("========================\n")
//console.log(os.constants.priority)


//同步方法
console.log("小王为顾客1下单。")
console.log("小王为顾客1送餐。")
console.log("小王为顾客2下单。")
console.log("小王为顾客2送餐。")
console.log("小王为顾客3下单。")
console.log("小王为顾客3送餐。")

//异步方法
console.log("异步：小王开始为顾客服务。");
//送餐服务
function service(){
    //setTimeout代码执行时，不会阻塞后面的代码执行
    setTimeout(function () {
        console.log("小王为顾客1送餐。");
    },0);
    setTimeout(function () {
        console.log("小王为顾客2送餐。");
    },0);
    setTimeout(function () {
        console.log("小王为顾客3送餐。");
    },0);
}
console.log("小王为顾客1下单。");
service();
console.log("小王为顾客2下单。");
console.log("小王为顾客3下单。");





console.log("===========异步调用=============\n")
var a = 0;
function fooA(x) {
     console.log(x)
}
function timer(time) {
     setTimeout(function () {
          a=6
     }, time);
}
console.log(a);
timer(3000);
fooA(a);